﻿using System;
using System.Collections;
using System.Collections.Generic;
using TimedTask.Enums;
using TimedTask.Tools;

namespace TimedTask.Models
{
    public class SelectLists
    {
        //声音列表
        private static IList<SelectListItem> _AudioList = new List<SelectListItem>();
        //任务编辑 - 天数列表
        private static IList<SelectListItem> _TaskDays = new List<SelectListItem>();
        //任务编辑 - 分钟
        private static IList<SelectListItem> _TaskMinutes = new List<SelectListItem>();
        //任务编辑 - 小时
        private static IList<SelectListItem> _TaskHours = new List<SelectListItem>();
        //任务编辑 - 月份
        private static IList<SelectListItem> _TaskMonths = new List<SelectListItem>();
        //任务类型
        private static IList<SelectListItem> _TaskTypes = new List<SelectListItem>();
        //文件类型
        private static IList<SelectListItem> _FileType = new List<SelectListItem>();
        //运行周期
        private static IList<SelectListItem> _RunType = new List<SelectListItem>();

        public static IList<SelectListItem> RunModes
        {
            get
            {
                if (_RunType.Count == 0)
                {
                    _RunType.Add(new SelectListItem { Text = "一次", Value = "5" });
                    _RunType.Add(new SelectListItem { Text = "每月", Value = "1" });
                    _RunType.Add(new SelectListItem { Text = "每周", Value = "6" });
                    _RunType.Add(new SelectListItem { Text = "每天", Value = "2" });
                    _RunType.Add(new SelectListItem { Text = "每小时", Value = "3" });
                    _RunType.Add(new SelectListItem { Text = "间隔分钟", Value = "4" });
                }
                return _RunType;
            }
        }

        public static IList<SelectListItem> FileType
        {
            get
            {
                if (_FileType.Count == 0)
                {
                    _FileType.Add(new SelectListItem { Text = "压缩文件", Value = "0" });
                    _FileType.Add(new SelectListItem { Text = "文件文件", Value = "1" });
                    _FileType.Add(new SelectListItem { Text = "办公文件", Value = "2" });
                    _FileType.Add(new SelectListItem { Text = "图片文件", Value = "3" });
                    _FileType.Add(new SelectListItem { Text = "视频文件", Value = "4" });
                    _FileType.Add(new SelectListItem { Text = "音频文件", Value = "5" });
                    _FileType.Add(new SelectListItem { Text = "自定义文件", Value = "6" });
                }
                return _FileType;
            }
        }

        public static IList<SelectListItem> TaskTypes
        {
            get
            {
                if (_TaskTypes.Count == 0)
                {
                    foreach (object s in Enum.GetValues(typeof(TaskType)))
                    {
                        string tmp = ((int)s).ToString();
                        object obj = Const.TaskTypes[tmp];
                        if (obj == null)
                            continue;

                        _TaskTypes.Add(new SelectListItem { Text = obj.ToString(), Value = tmp });
                    }
                }
                return _TaskTypes;
            }
        }

        public static IList<SelectListItem> TaskMonths
        {
            get
            {
                if (_TaskMonths.Count == 0)
                {
                    for (int i = 1; i <= 12; i++)
                    {
                        _TaskMonths.Add(new SelectListItem { Text = i.ToString(), Value = i.ToString() });
                    }
                }
                return _TaskMonths;
            }
        }

        public static IList<SelectListItem> TaskHours
        {
            get
            {
                if (_TaskHours.Count == 0)
                {
                    for (int i = 1; i <= 24; i++)
                    {
                        _TaskHours.Add(new SelectListItem { Text = i.ToString(), Value = i.ToString() });
                    }
                }
                return _TaskHours;
            }
        }

        public static IList<SelectListItem> TaskMinutes
        {
            get
            {
                if (_TaskMinutes.Count == 0)
                {
                    for (int i = 0; i <= 480; i++)
                    {
                        _TaskMinutes.Add(new SelectListItem { Text = i.ToString(), Value = i.ToString() });
                    }
                }
                return _TaskMinutes;
            }
        }

        public static IList<SelectListItem> TaskDays
        {
            get
            {
                if (_TaskDays.Count == 0)
                {
                    for (int i = 1; i <= 31; i++)
                    {
                        _TaskDays.Add(new SelectListItem { Text = i.ToString(), Value = i.ToString() });
                    }
                }
                return _TaskDays;
            }
        }
        public static IList<SelectListItem> AudioList
        {
            get
            {
                if (_AudioList.Count == 0)
                {
                    foreach (DictionaryEntry de in Const.Audios)
                    {
                        _AudioList.Add(new SelectListItem { Text = de.Key.ToString(), Value = de.Key.ToString() });
                    }
                }
                return _AudioList;
            }
        }
    }
}
